import axios from 'axios';
import Qs from 'qs'
////防止Axios同一请求发送两次，会先发送预请求（OPTIONS），也可以后端加配置项，判断为options请求时不做任何处理
axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
axios.defaults.transformRequest = [obj => Qs.stringify(obj)]
//防止出现sessionID不一致的情况
axios.defaults.withCredentials = true

var host = 'http://172.18.245.87:8889';
host='http://10.10.126.252:8889';
//登录退出
const requestLogin = params => {
    return axios.post(host+"/auth/login", params).then(res => res.data);
};
const requestLogout = () => {
    return axios.post(host+"/auth/logout").then(res => res.data);
};
const LoginApi = {
    requestLogin,
    requestLogout
}
//菜单
const getLeftMenus = () => {
    return axios.post(host+"/menu/getLeftMenus").then(res => res.data)
}
const getAllMenus = () => {
    return axios.post(host+"/menu/getAllMenus").then(res => res.data);
}
const getMenuinfo = param => {
    //{roleId:1}
    return axios.post(host+"/menu/getMeunsIdsByRole",param).then(res => res.data); 
}
const MenusApi = {
    getAllMenus,
    getLeftMenus,
    getMenuinfo
}
//功能
const getAllFnlist = () => {
    return axios.post(host+"/function/getFunctionList").then(res => res.data);
}
const getFnDetail = id=>{
    return axios.post(host+"/function/getFunction/"+id).then(res => res.data);
}
const addFnDetail = params=>{
    /**
     * funcname:功能标题 ; invokeentry:功能地址; funcno:自定义编号;classname:图标;invoketype:打开方式  功能类别 = 0,URL默认调用 = 1,动态调用 = 2,静态调用 = 4,外部调用 = 8,全局窗口打开 = 16，新窗口中打开 = 32
     * status:状态   1-启用  0-禁用 ;parentfuncid:父级id  默认0
     */
    return axios.post(host+"/function/addFunction", params).then(res => res.data);   
}
const editFnDetail = params=>{
    /**
     * funcname:功能标题 ; invokeentry:功能地址; funcno:自定义编号;classname:图标;invoketype:打开方式  功能类别 = 0,URL默认调用 = 1,动态调用 = 2,静态调用 = 4,外部调用 = 8,全局窗口打开 = 16，新窗口中打开 = 32
     * status:状态   1-启用  0-禁用 ;parentfuncid:父级id  默认0; funcid:功能id
     */
    return axios.post(host+"/function/editFunction", params).then(res => res.data);   
}
const delFnDetail = id=>{
    return axios.post(host+"/function/cancle/"+id).then(res => res.data);
}
const FnManageApi = {
    getAllFnlist,getFnDetail,addFnDetail,editFnDetail,delFnDetail
}
//////////////////////////////企业内部管理////////////////////////////////
///////员工管理//////
//获取列表
const getStaffList = params => {
    return axios.post(host+"/staff/getStaffList", params).then(res => res.data);
};
//添加
const addStaffMsg = params => {
    return axios.post(host+"/staff/addStaffMsg", params).then(res => res.data);
};
//应用
const applyStaffMsg = params => {
    return axios.post(host+"/staff/applyStaffMsg", params).then(res => res.data);
};
//删除
const deleteStaffMsg = params => {
    return axios.post(host+"/staff/deleteStaffMsg", params).then(res => res.data);
};
//获取家庭成员列表
const getFamilyList = params => {
    return axios.post(host+"/staff/getFamilyList", params).then(res => res.data);
};
//上传图片
const uploadStaffImg = params => {
    return axios.post(host+"/staff/uploadStaffImg", params).then(res => res.data);
};
const staff={
  getStaffList,deleteStaffMsg,getFamilyList,applyStaffMsg,addStaffMsg,uploadStaffImg
}
///////////////////////////////固定资产列表///////////////////////////////////////
//列表
const getFixedAssetsList = params => {
    return axios.post(host+"/assets/getFixedAssetsList", params).then(res => res.data);
};
//添加
const addFixedAssets = params => {
    return axios.post(host+"/assets/addFixedAssets", params).then(res => res.data);
};
//删除
const deleteFixedAssets = params => {
    return axios.post(host+"/assets/deleteFixedAssets", params).then(res => res.data);
};
//获取所有的领用人/监察人信息
const getAllUsedList = params => {
    return axios.post(host+"/assets/getAllUsedList", params).then(res => res.data);
};

const assets={
  getFixedAssetsList,deleteFixedAssets,addFixedAssets
}
/////////////////////////卫生检查记录//////////////////////////
//获取列表
const getHealthCheckList = params => {
    return axios.post(host+"/health/getHealthCheckList", params).then(res => res.data);
};
//添加
const addHealthCheck = params => {
    return axios.post(host+"/health/addHealthCheck", params).then(res => res.data);
};
//删除
const deleteHealthCheck = params => {
    return axios.post(host+"/health/deleteHealthCheck", params).then(res => res.data);
};

const health={
  getHealthCheckList,deleteHealthCheck,addHealthCheck
}
///////////////////////外部文件收发///////////////////////
//列表
const getExternalFileList = params => {
    return axios.post(host+"/external/getExternalFileList", params).then(res => res.data);
};
//添加
const addExternalFile = params => {
    return axios.post(host+"/external/addExternalFile", params).then(res => res.data);
};
//删除
const deleteExternalFile = params => {
    return axios.post(host+"/external/deleteExternalFile", params).then(res => res.data);
};

const external={
  getExternalFileList,addExternalFile,deleteExternalFile
}
////////////////////////////公司通知//////////////////////////
//列表
const getCompanyNoticeList = params => {
    return axios.post(host+"/notice/getCompanyNoticeList", params).then(res => res.data);
};
//删除
const deleteCompanyNotice = params => {
    return axios.post(host+"/notice/deleteCompanyNotice", params).then(res => res.data);
};
//新建
const addCompanyNotice = params => {
    return axios.post(host+"/notice/addCompanyNotice", params).then(res => res.data);
};
const notice={
  getCompanyNoticeList,addCompanyNotice,deleteCompanyNotice
}
///////////////////////////文件阅办单管理//////////////////////////////
//列表
const getFileReadList = params => {
    return axios.post(host+"/fileread/getFileReadList", params).then(res => res.data);
};
//新增
const addFileRead = params => {
    return axios.post(host+"/fileread/addFileRead", params).then(res => res.data);
};
//删除
const deleteFileRead = params => {
    return axios.post(host+"/fileread/deleteFileRead", params).then(res => res.data);
};
//注销
const rejectFileRead = params => {
    return axios.post(host+"/fileread/rejectFileRead", params).then(res => res.data);
};
const fileread={
  getFileReadList,addFileRead,deleteFileRead,rejectFileRead
}
//获取文件审核列表
const getFileAduitList = params => {
    return axios.post(host+"/file/getFileAduitList", params).then(res => res.data);
};
//获取文件发布列表
const getFileReleaseList = params => {
    return axios.post(host+"/file/getFileReleaseList", params).then(res => res.data);
};
//获取文件查阅列表
const getFileQueryList = params => {
    return axios.post(host+"/file/getFileQueryList", params).then(res => res.data);
};
//进行审核
const aduitFileMess = params => {
    return axios.post(host+"/file/aduitFileMess", params).then(res => res.data);
};
//进行发布
const releaseFileMess = params => {
    return axios.post(host+"/file/releaseFileMess", params).then(res => res.data);
};
//////////////////////////员工考勤////////////////////////////////
//列表
const getAttendanceList = params => {
    return axios.post(host+"/atten/getAttendanceList", params).then(res => res.data);
};
//删除
const deleteAttendance = params => {
    return axios.post(host+"/atten/deleteAttendance", params).then(res => res.data);
};
//导入
const importAttendance = params => {
    return axios.post(host+"/atten/importAttendance", params).then(res => res.data);
};
//添加
const addAttendance = params => {
    return axios.post(host+"/atten/addAttendance", params).then(res => res.data);
};
//下载excel文件
const loadAttendance = params => {
    return axios.post(host+"/atten/loadAttendance", params).then(res => res.data);
};

const atten={
  getAttendanceList,importAttendance,deleteAttendance,addAttendance,loadAttendance
}
///////////////////////////部门管理///////////////////////////////
//获取列表
const getDeptList = params => {
    return axios.post(host+"/dept/getDeptList", params).then(res => res.data);
};
//添加
const addDeptMessage = params => {
    return axios.post(host+"/dept/addDeptMessage", params).then(res => res.data);
};
//删除
const deleteDeptMessage = params => {
    return axios.post(host+"/dept/deleteDeptMessage", params).then(res => res.data);
};
//获取所有的部门
const getAllDept = params => {
    return axios.post(host+"/dept/getAllDept", params).then(res => res.data);
};

const dept={
  getDeptList,deleteDeptMessage,addDeptMessage,getAllDept
}
///////////////////////员工请假管理/////////////////////////
//列表
const getStaffLeaveList = params => {
    return axios.post(host+"/leave/getStaffLeaveList", params).then(res => res.data);
};
//注销
const rejectStaffLeave = params => {
    return axios.post(host+"/leave/rejectStaffLeave", params).then(res => res.data);
};
//删除
const deleteStaffLeave = params => {
    return axios.post(host+"/leave/deleteStaffLeave", params).then(res => res.data);
};
//添加
const addStaffLeave = params => {
    return axios.post(host+"/leave/addStaffLeave", params).then(res => res.data);
};

const leave={
  getStaffLeaveList,deleteStaffLeave,addStaffLeave,rejectStaffLeave
}
///////////////////////公章使用记录//////////////////////////////////////
//列表
const getSealRecordList = params => {
    return axios.post(host+"/seal/getSealRecordList", params).then(res => res.data);
};
//添加
const addSealRecord = params => {
    return axios.post(host+"/seal/addSealRecord", params).then(res => res.data);
};
//删除
const deleteSealRecord = params => {
    return axios.post(host+"/seal/deleteSealRecord", params).then(res => res.data);
};
//注销
const rejectSealRecord = params => {
    return axios.post(host+"/seal/rejectSealRecord", params).then(res => res.data);
};

const seal={
  getSealRecordList,deleteSealRecord,addSealRecord,rejectSealRecord
}
///////////////////////////文件分发内容/////////////////////////////
//获取文件分发审核列表
const getFileIssueAduitList = params => {
    return axios.post(host+"/seal/getFileIssueAduitList", params).then(res => res.data);
};
//获取详情
const getFileIssueAduitDetail = params => {
    return axios.post(host+"/seal/getFileIssueAduitDetail", params).then(res => res.data);
};
//进行审核
const aduitFileIssue = params => {
    return axios.post(host+"/seal/aduitFileIssue", params).then(res => res.data);
};
//获取文件分发发布列表
const getFileIssuePublish = params => {
    return axios.post(host+"/seal/getFileIssuePublish", params).then(res => res.data);
};
//文件发布
const publishFileIssue = params => {
    return axios.post(host+"/seal/publishFileIssue", params).then(res => res.data);
};
//获取文件分发审阅列表
const getFileIssueQueryList = params => {
    return axios.post(host+"/seal/getFileIssueQueryList", params).then(res => res.data);
};

////////////////////////////////////////////////////////////////////////
export{
    LoginApi,MenusApi,FnManageApi,
  staff,assets,getAllUsedList,health,external,notice,fileread,
  getFileAduitList,getFileReleaseList,getFileQueryList,aduitFileMess,releaseFileMess,
  atten,dept,leave,seal,
  getFileIssueAduitList,getFileIssueAduitDetail,aduitFileIssue,getFileIssuePublish,
  publishFileIssue,getFileIssueQueryList
}
